package com.cn.sl.server.common.dto

import com.querydsl.core.types.dsl.BooleanExpression
import com.querydsl.core.types.dsl.NumberPath

interface NumberRangeAble<T, F : NumberPath<T>> : RangeAble<T, F> where T : Comparable<*>, T : Number {
    override fun between(fieldPath: F): BooleanExpression {
        return if (this.min != null && this.max == null) {
            fieldPath.goe(this.min)
        } else if (this.min == null && this.max != null) {
            fieldPath.loe(this.max)
        } else {
            fieldPath.between(this.min, this.max)
        }
    }
}